using System;
using System.Collections.Generic;
using System.Text;
using BusinessObjects.BO_Actions.Members;
using Entity.StoreProcedure;
using BusinessObjects;
using System.Data;
using BussinessObjects.BO_Actions;
namespace BusinessObjects.BO_GetObjects 
{
	public static class BO_Members
	{
		public static DataTable SelectAll(int status)
		{
			try
			{
				BOMembers_Select_All action = new BOMembers_Select_All();
				usp_Members_Select_All entity = new usp_Members_Select_All();
				entity.STATUS = status;
				return action.ExecuteAndReturnDataTable(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public static DataTable SelectTop(int rows, int status)
		{
			try
			{
				BOMembers_Select_Top action = new BOMembers_Select_Top();
				usp_Members_Select_Top entity = new usp_Members_Select_Top();
				entity.NUMBERRECORD = rows;
				entity.STATUS = status;
				return action.ExecuteAndReturnDataTable(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public static DataTable Search(int  member_id)
		{
			try
			{
				BOMembers_Search action = new BOMembers_Search();
				usp_Members_Search entity = new usp_Members_Search();
				entity.MEMBER_ID = member_id;
				return action.ExecuteAndReturnDataTable(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public static DataTable SelectWithPaged(int startIndex, int pageCount, int status)
		{
			try
			{
				BOMembers_Select_WithPaged action = new BOMembers_Select_WithPaged ();
				usp_Members_Select_WithPaged entity = new usp_Members_Select_WithPaged ();
				entity.STARTINDEX = startIndex;
				entity.MAXRECORDS = pageCount;
				entity.STATUS = status;
				return action.ExecuteAndReturnDataTable(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public static string Insert( int region_id, string member_code, string user_name, string pass_word, string full_name, string address, string fax, string mobile, string email, decimal left_money, DateTime last_login, DateTime last_sms, DateTime last_recharge, bool is_personal, bool is_vip, bool is_active, bool is_receive_newsletter, DateTime created_date, string created_by, DateTime modify_date, string modify_by, int status)
		{
			try
			{
				BOMembers_Insert action = new BOMembers_Insert();
				usp_Members_Insert entity = new usp_Members_Insert();
				entity.REGION_ID = region_id;
				entity.MEMBER_CODE = member_code;
				entity.USER_NAME = user_name;
				entity.PASS_WORD = pass_word;
				entity.FULL_NAME = full_name;
				entity.ADDRESS = address;
				entity.FAX = fax;
				entity.MOBILE = mobile;
				entity.EMAIL = email;
				entity.LEFT_MONEY = left_money;
				entity.LAST_LOGIN = last_login;
				entity.LAST_SMS = last_sms;
				entity.LAST_RECHARGE = last_recharge;
				entity.IS_PERSONAL = is_personal;
				entity.IS_VIP = is_vip;
				entity.IS_ACTIVE = is_active;
				entity.IS_RECEIVE_NEWSLETTER = is_receive_newsletter;
				entity.CREATED_DATE = created_date;
				entity.CREATED_BY = created_by;
				entity.MODIFY_DATE = modify_date;
				entity.MODIFY_BY = modify_by;
				entity.STATUS = status;
				return action.ExecuteAndReturnStringValue(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public static string Update( Int64 member_id, int region_id, string member_code, string user_name, string pass_word, string full_name, string address, string fax, string mobile, string email, decimal left_money, DateTime last_login, DateTime last_sms, DateTime last_recharge, bool is_personal, bool is_vip, bool is_active, bool is_receive_newsletter, DateTime created_date, string created_by, DateTime modify_date, string modify_by, int status)
		{
			try
			{
				BOMembers_Update action = new BOMembers_Update();
				usp_Members_Update entity = new usp_Members_Update();
				entity.MEMBER_ID = member_id;
				entity.REGION_ID = region_id;
				entity.MEMBER_CODE = member_code;
				entity.USER_NAME = user_name;
				entity.PASS_WORD = pass_word;
				entity.FULL_NAME = full_name;
				entity.ADDRESS = address;
				entity.FAX = fax;
				entity.MOBILE = mobile;
				entity.EMAIL = email;
				entity.LEFT_MONEY = left_money;
				entity.LAST_LOGIN = last_login;
				entity.LAST_SMS = last_sms;
				entity.LAST_RECHARGE = last_recharge;
				entity.IS_PERSONAL = is_personal;
				entity.IS_VIP = is_vip;
				entity.IS_ACTIVE = is_active;
				entity.IS_RECEIVE_NEWSLETTER = is_receive_newsletter;
				entity.CREATED_DATE = created_date;
				entity.CREATED_BY = created_by;
				entity.MODIFY_DATE = modify_date;
				entity.MODIFY_BY = modify_by;
				entity.STATUS = status;
				return action.ExecuteAndReturnStringValue(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public static bool Delete(int member_id)
		{
			try
			{
				BOMembers_Delete action = new BOMembers_Delete();
				usp_Members_Delete entity = new usp_Members_Delete();
				entity.MEMBER_ID = member_id;
				return action.ExecuteAndReturnBooleanValue(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public static bool Restore(int member_id)
		{
			try
			{
				BOMembers_Restore action = new BOMembers_Restore();
				usp_Members_Restore entity = new usp_Members_Restore();
				entity.MEMBER_ID = member_id;
				return action.ExecuteAndReturnBooleanValue(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
        public static DataTable Login(string user, string password)
        {
            try
            {
                BOMemberLogin action = new BOMemberLogin();
                usp_MemberLogin entity = new usp_MemberLogin();
                entity.USERNAME = user;
                entity.PASSWORD = password;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
	}
}

